package com.pipe.servicepipe.sms.listener;

import com.pipe.servicepipe.sms.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @ClassName SmsListener
 * @Author HETAO
 * @Date 2020/7/19 11:00
 */
@Component
@Slf4j
@RabbitListener(queuesToDeclare = @Queue("pipe.login.sms"))
public class SmsListener {
    @Resource
    private SmsService smsService;

    @RabbitHandler
    public void handle(Map map){
        String phone = map.get("phone").toString();
        String  number = map.get("phone").toString();
        smsService.sendSms(phone,number);
        log.info("phone captcha code:{}",number);
    }
}
